package test;

import org.w3c.dom.ls.LSOutput;

public class test16StringBuilderBottomLayer {
    public static void main(String[] args) {
        StringBuilder sb=new StringBuilder();
        //查看初始容量
        System.out.println("初始容量"+sb.capacity());//16
        System.out.println("初始长度"+sb.length());//0
        //初始化长度
        sb.append("abc");
        System.out.println("容量"+sb.capacity());//16
        System.out.println("长度为"+sb.length());//3
        //当内容长度大于容量时
        sb.append("cdefghijklmnuopqistxz");
        System.out.println("当内容长度大于容量时的容量"+sb.capacity());//扩容为2*初始化+2=34
        System.out.println("长度"+sb.length());
        //当内容长度大于34时容量随着长度的变化而变化
        sb.append("1234567890");
        System.out.println("当内容长度大于34时容量随着长度的变化而变化，容量："+sb.capacity());
        System.out.println("长度"+sb.length());

    }


}
